<template>
  <div>
    <el-form ref="myform" :model="formItem" :rules="rules" label-width="100px" size="mini">
      <el-row>
        <el-col :span="24">
          <el-form-item label="请确认此流程" prop="result">
            <el-radio-group v-model="formItem.result">
              <el-radio :label="1">通过</el-radio>
              <!-- <el-radio :label="0">不通过</el-radio> -->
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :offset="20" :span="4">
          <div style="display:block;margin-top:10px;text-align:right">
            <el-button size="mini" @click="btnCancel">取 消</el-button>
            <el-button size="mini" type="primary" @click="commit">提 交</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { confirm } from '@neu/dcam-ui/api/itsm'

const formItem = {
  workOrderNum: '',
  taskId: '',
  title: '',
  result: 1
}
export default {
  props: {
    taskId: {
      required: false,
      type: String,
      default: 'NULL'
    },
    workOrderNum: {
      required: false,
      type: String,
      default: ''
    }
  },
  data() {
    return {
      formItem: {
        ...formItem
      },
      rules: {
        result: [{ required: true, message: '审批不能为空', trigger: 'blur' }]
      }
    }
  },
  created() {
    this.fetch()
  },
  methods: {
    // 获取借用工单信息
    fetch() {
      this.formItem.result = 1
    },
    commit() {
      this.$refs.myform.validate((valid) => {
        if (valid) {
          const data = { ...this.formItem }
          data.workOrderNum = this.workOrderNum
          data.taskId = this.taskId
          confirm(data).then(res => {
            if (res.status === 'success') {
              this.$emit('cancelNewOrderForm', 'refresh')
            }
          })
        }
      })
    },
    btnCancel() {
      this.$emit('cancelNewOrderForm', 'refresh')
    }
  }
}
</script>
<style>
  .el-table th.gutter{
    display: table-cell !important;
  }
</style>
